/********************************************************************

Write Date: 2015/04/23
Author: Apple
>>>> Create class ResourceSaver

*********************************************************************/
#pragma once
#include "ooputils_global.h"
#include <QDataStream>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include "Object.h"
#include "Ptr.h"



_NS_OOP_BEGIN



/**
 * 
 *
 * Thread-safe: false.
 *
 * @remarks 2015/08/17, Apple
 */
class ResourceSaver
{
public:

	ResourceSaver ();

	void saveObject (P_Object p_obj);

	template< class T >
	ResourceSaver& operator<< (const T& r_data);

	template< class T >
	ResourceSaver& operator<< (const Ptr< T > p_data);

	template< class T >
	ResourceSaver& operator<< (const std::complex< T >& r_val);

	template< class T1, class T2 >
	ResourceSaver& operator<< (const std::pair< T1, T2 >& r_val);

	template< class T, class _ALLOC >
	ResourceSaver& operator<< (const std::vector< T, _ALLOC >& r_val);

	template< class T, class _ALLOC >
	ResourceSaver& operator<< (const std::set< T, _ALLOC >& r_val);

	template< class T1, class T2, class _PR, class _ALLOC >
	ResourceSaver& operator<< (const std::map< T1, T2, _PR, _ALLOC >& r_val);

	template< class T >
	void writeArray (const T* data, size_t count);

	template< class T, class _ALLOC >
	void writeSimpleVector (const std::vector< T, _ALLOC >& r_vector);

private:

	QDataStream _outStream;

};



_NS_OOP_END



#include "ResourceSaver.hpp"